﻿using AutoMapper;
using LPY.LeHealth.DTO;
using LPY.LeHealth.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LPY.LeHealth.Service
{
    /// <summary>
    /// 公共服务
    /// </summary>
    public class CommonService
    {
        /// <summary>
        /// 用户信息Session主键
        /// </summary>
        public static string UserSessionName = "UserSessionName";
        /// <summary>
        /// 医院Session主键
        /// </summary>
        public static string HospitalSessionName = "HospitalSessionName";
        /// <summary>
        /// 管理员Session主键
        /// </summary>
        public static string AdminSessionName = "AdminSessionName";


        /// <summary>
        /// 注册映射管理
        /// </summary>
        public static void RegisterMap()
        {
            Mapper.Initialize(cnf => { 
                cnf.CreateMap<UserDTO, User>();
                cnf.CreateMap<HospitalDTO, Hospital>()
                    .ForMember(n => n.GradeName, opt => opt.MapFrom(name => name.Grade.Name))
                    .ForMember(n => n.AreaName, opt => opt.MapFrom(name => name.Area.Name));
                cnf.CreateMap<PhysicalItem, PhysicalItemDTO>();
                cnf.CreateMap<PhysicalItemDTO, PhysicalItem>();
                cnf.CreateMap<ComboDTO, Combo>();
                cnf.CreateMap<Combo, ComboDTO>();
                cnf.CreateMap<ComboTypeDTO, ComboType>();
                cnf.CreateMap<ComboToPhysicalItemDTO, PhysicalItem>()
                    .ForMember(n => n.Id, opt => opt.MapFrom(name => name.PhysicalItemId));

                cnf.CreateMap<Hospital, HospitalDTO>();
                cnf.CreateMap<Personalized_ExaminationDTO, Personalized__Examination>();
                cnf.CreateMap<Order, Order>();
                
            });
        }
    }
}
